<template>
  <div>
    <!-- 面包屑导航区 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>参数列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card>
        <!-- 警告区域 -->
       <el-alert show-icon title="注意：只允许为第三级分类设置相关参数" type="warning" :closable='false'></el-alert>
        <!-- 选择商品分类区域 -->
        <el-row class="cat_opt">
            <el-col>
                <span>选择商品分类：</span>
                <!-- 选择商品分类的级联选择框 -->
                <el-cascader
                   v-model="selectedCateKeys"
                  :options="catelist"
                  :props='cateProps'
                  @change="handleChange">
                </el-cascader>
            </el-col>
        </el-row>
        <!-- tab 页签区域 -->
         <el-tabs v-model="activeName" @tab-click="handleTabClick">
            <el-tab-pane label="动态参数" name="first">
                <el-button type='primary' size='mini'>添加参数</el-button>
            </el-tab-pane>
            <el-tab-pane label="静态属性" name="second">
                <el-button type='primary' size='mini'>添加属性</el-button>
            </el-tab-pane>
         </el-tabs>
    </el-card>
  </div>
</template>
<script>
export default {
  data () {
    return {
      catelist: [],
      cateProps: {
        value: 'cat_id',
        label: 'cat_name',
        children: 'children'
      },
      selectedCateKeys: [],
      TabPane: 'first',
      activeName: ''
    }
  },
  created () {
    this.getCateList()
  },
  methods: {
    async getCateList () {
      const { data: res } = await this.$http.get('categories')
      if (res.meta.status !== 200) {
        return this.$message.error('获取商品分类失败')
      }
      this.catelist = res.data
    },
    handleChange () {
      if (this.selectedCateKeys.length !== 3) {
        this.selectedCateKeys = []
      }
    },
    handleTabClick () {
      console.log(this.activeName)
    }
  }
}
</script>

<style scoped>
.cat_opt {
  margin: 15px 0;
}
</style>
